<%--
  Created by IntelliJ IDEA.
  User: FK
  Date: 2018/1/4
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
<head>
    <title>宣传阵地</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8 ? MYOA_CHARSET : htmlspecialchars($HTML_PAGE_CHARSET))?>" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=0.3, user-scalable=0, minimum-scale=0, maximum-scale=5.0,user-scalable=yes">
    <link rel="stylesheet" type="text/css" href="/css/street/street.css"/>
    <link rel="stylesheet" href="/css/officialDocument/officialDocument.css">
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <%--<link rel="stylesheet" type="text/css" href="/css/patrol/patrol.css"/>--%>
    <link rel="stylesheet" href="/css/base.css">
    <script src="/js/jquery/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layer/layer.js?20201106" type="text/javascript" charset="utf-8"></script>
<%--    <script src="/js/street/base/base.js" type="text/javascript" charset="utf-8"></script>--%>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/base/tablePage.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <script src="../js/jquery/jquery.cookie.js"></script>
    <style>
        body{
            margin:0px;
        }
        .info{
            width:180px;
            height:28px;
            border-radius: 3px;
            margin-left:20px;
            vertical-align: middle;
        }
        button{
            background: #2f8ae3;
            margin-left: 10px;
            padding: 5px 10px;
            border-radius: 4px;
            color: #fff;
            cursor: pointer;
            font-size:14px;
        }
        #add{
            float:right;
            margin:0px 40px 10px 0px;
        }
        .table{
            width:96%;
            margin:20px auto 0px;
        }
        .tableFoot{
            margin-top:20px;
        }
        .mainBg .mainTitle{
            height: 89%;

        }
        .childCheck{
            width:16px;
            vertical-align: middle;
        }

        #checkAll{
            margin-left:10px;
        }
        #outport{
            background: #009900
        }
        #inportEdit{
            background: #009900;
        }
        .M-box3 .active{
            margin: 0px 3px;
            width: 29px;
            height: 29px;
            line-height: 29px;
            background: #2b7fe0;
            font-size: 12px;
            border: 1px solid #2b7fe0;
            color:#fff;
            text-align:center;
            display: inline-block;
        }
        .M-box3 a{
            margin: 0 3px;
            width: 29px;
            height: 29px;
            line-height: 29px;
            font-size: 12px;
            display: inline-block;
            text-align:center;
            background: #fff;
            border: 1px solid #ebebeb;
            color: #bdbdbd;
            text-decoration: none;
        }
        .mainBg .mainTitle{
            min-width: 750px;
        }
        .mainTitleUl .bordercolor span{
            font-size:14px;
        }
        .mainTitleUl .bordercolor label input[type=text]{
            font-size:14px;
        }
        .mainBg{
            padding-top:0px;
        }
        .mainBg .mainTitle{
            height:125% !important;
        }
        #grid{
            background: none!important;
        }
        .mainTitleUl .bordercolor label{
            text-align: left;
        }
        .preservation{
            margin-top:61px!important;
        }
        .lue{
            width:200px;
            overflow: hidden;
            margin:0 auto;
            text-overflow:ellipsis;
            white-space:nowrap;
        }
        b {
            color: red;
            display: inline-block;
            vertical-align: middle;
            margin: 5px 5px 0px;
            font-size: 20px;
        }
        @media  screen and (max-width: 1366px)  {
            .mainTitle{
                padding-bottom:50px!important;
            }

        }
    </style>
    <link rel="stylesheet" href="/css/biaodan.css">
</head>
<body>

<div class="content" >
    <div style="    height: 45px;border-bottom: 1px solid #dddddd;" id="iframe14">
        <div class="headImg" style="    width: 23px;
    height: 23px;
    margin-left: 21px;">
            <img style="    margin-top: 10px;width: 100%;height: 100%" src="/img/document/icon_agentDispatch.png" alt="">
        </div>

        <div class="divTitle" style="font-size: 22px;    margin-left: 46px;line-height: 0;">
            宣传阵地
        </div>
    </div>
    <div class="tableList" style="margin-top: 13px;">
        <div class="headNav">
            <%--<input type="text" class="info" placeholder="企业信息">--%>
            <%--<select class="info" name="xiala" id="">--%>
                <%--<option value="0">所有处理结果</option>--%>
                <%--<option value="1">完成</option>--%>
                <%--<option value="2">未完成</option>--%>
            <%--</select>--%>
            <%--<button id="query">查询</button>--%>
            <%--<button id="inport" style="margin-left:28px;">导入</button>--%>
            <%--<button id="inportEdit">导入修改</button>--%>
            <button class="choose" id="add" data-type="0">新建</button>
<%--            <button id="inport" style="margin-left:28px;">导入</button>--%>
<%--            &lt;%&ndash;<button id="inportEdit">导入修改</button>&ndash;%&gt;--%>
<%--            <button class="choose" id="add" data-type="0">新建</button>--%>
        </div>
        <div class="table">
            <table>
                <thead>
                <tr>
                    <%--<th style="width:1%"></th>--%>
                    <th>序号</th>
                    <th>网格名称</th>
                    <th>活动场所</th>
                    <th>名称</th>
                    <th>位置</th>
                    <th>面积</th>
                    <%--<th>用途</th>--%>
                    <%--<th>负责人联系方式</th>--%>
                    <%--<th>卫生许可证</th>--%>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody class="list">

                </tbody>
            </table>
            <div class="tableFoot">
                <%--<input type="checkbox" id="checkAll"  style="width:16px;vertical-align: middle">--%>
                <%--<label for="checkAll" style="font-size:14px;">全选</label>--%>
                <%--<button id="outport">导出</button>--%>
            </div>

        </div>
        <div style="margin: -10px auto 0px;height:50px;width: 97%;" class="clearfix">
            <div id="dbgz_page" class="M-box3" style="display:none;">

            </div>
        </div>
    </div>
    <div class="mainBg" style="background: #fff;display: none">
        <form action="/position/addActivity" id="datasave">
            <%--<input type="file"  onchange="filesTwo(this)" multiple="multiple" name="file"--%>
            <%--style="display: none"/>--%>
            <%--<input type="hidden" name="userId">--%>
            <input type="hidden" name="">
            <input type="hidden" name="">
            <div class="mainTitle">
                <ul class="mainTitleUl">
                    <li style="padding-top: 10px;text-align: center;height: 10px !important;border-bottom: none !important;"><span class="spanSize"></span> </li>

                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff;margin-top: -26px;"><b>*</b>组织架构</span>
                        <label style="width: 80%;margin-top: -32px;">
                            <input type="text" name="orgDeptId" id="orgDeptId" style="display:none;"/>
                            <input type="text" id="deptParent" name="deptParent" readonly="readonly" placeholder="请选择组织架构" style="background: #fcfcfc;width: 55%;float: none;margin-top:17px "  dept_id="">
                            <a class="release3 addDept"  style="margin-left: 10px;cursor: pointer">添加</a>
                            <a class="release3 clearDept" style="margin-left: 5px;cursor: pointer">清除</a>
                        </label>


                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff;">坐标<b style="color: red;">*</b></span>
                        <label style="width: 47%;position:relative">
                            <input type="text" name="gridLocation" style="width:92%" readonly="readonly">
                            <%--<input type="hidden" name="gridLocation">--%>
                            <button type="button" class="dwbtn" style="position: absolute;width: 82px;height: 39px; background-color: #228cdc;color: #fff; right: -62px;top:9px;border-radius: 3px;cursor: pointer;">点击定位</button>
                        </label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff;margin-top: -12px;">活动场所</span>
                        <label>
                            <input type="text" name="activityPlace"  placeholder="请填写活动场所" style="background: #fcfcfc;width: 147%;float: none; margin-top: -4px;">
                        </label>
                        <label style="width: 50%;"></label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff;margin-top: -22px;">名称</span>
                        <label>
                            <input type="text" name="name"  placeholder="请填写名称" style="background: #fcfcfc;    width: 147%;float: none;margin-top:-16px;">
                        </label>
                        <label style="width: 50%;"></label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff;margin-top: -36px;">位置</span>
                        <label>
                            <input type="text" id="times" name="place" placeholder="请填写位置" style="background: #fcfcfc;    width: 147%;float: none; margin-top: -28px;">
                        </label>
                        <label style="width: 50%;"></label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff;margin-top: -46px;">面积</span>
                        <label>
                            <input type="text" name="area" placeholder="请填写面积" style="background: #fcfcfc;    width: 147%;float: none; margin-top: -40px;">
                        </label>
                        <label style="width: 50%;"></label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff;margin-top: -57px;">用途</span>
                        <label style="    height: 89px;">
                            <textarea name="application" id="application" style="background: #fcfcfc; width: 147%;height: 70px!important;font-size:14px;float: none; margin-top: -51px;"></textarea>
                            <%--<input type="text" name="application"  placeholder="请填写用途" style="background: #fcfcfc;    width: 147%;float: none; margin-top: -53px;">--%>
                        </label>
                        <label style="width: 50%;"></label>
                    </li>
                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff; margin-top: -76px;">备注</span>
                        <label>
                            <%--<input type="text" name="remark1" style="background: #fcfcfc; width: 147%;float: none; margin-top: -66px;margin-left: 66%;">--%>
                            <textarea name="remark1" id="remark1" style="background: #fcfcfc; width: 147%;height: 70px!important;font-size:14px;float: none; margin-top: -66px;margin-left: 66%;"></textarea>
                        </label>
                    </li>

                </ul>
                <div style="height: 100px;line-height: 80px;text-align: center;    margin-top: -95px;">
                <div style="display: flex;justify-content: center;width: 100%;">
                    <a href="javascript:void (0)" class="preservation" style="
               display: inline-block;margin-right: 10px;
                line-height: 1;font-size:18px;padding: 8px 20px;
                background: #2F8AE3;color: #fff;border-radius: 6px">保存</a>
                    <a href="javascript:void (0)" class="getBack"  style="
                display: inline-block;
                line-height: 1;font-size:18px;padding: 8px 20px;background: #2F8AE3;color: #fff;border-radius: 6px">返回</a>
                </div>
                </div>
            </div>
        </form>
    </div>
</div>

<script>
    // 获取地址栏参数值
    function getQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
    // debugger
    var tag = getQueryString("tag");
    if(tag==1){
        $(".table").css('margin-top','50px')
        $("#add").css('background','#2f8ae3')
        $("#add").css('padding','4px 13px')
        $("#add").css('margin-top','8px')
        $('body').css('background','#f2f2f2')
        $('#iframe14').css('display','none')
    }else{
        $("#add").css("display","none")
        $("#de").css("display","none")
        $("#up").css("display","none")

    }
    var dept_id;

    $(".addDept").on("click",function(){
        dept_id='deptParent';
        $.popWindow("/common/selectDeptshiyuan");
    });

    $('.clearDept').click(function () {
        $('#deptParent').val("");
    });

    $(document).on('click','.choose',function(){
        var type=$(this).attr('data-type');
        // $('.tableList').hide();
        // $('.mainBg').show();
        $('#communityNo').val("");

        if(type==0){//新建
            $('.tableList').hide();
            $('.mainBg').show();
            $('.preservation').attr('data-type','0');
            $('.preservation').show();
            $('.release3').show();
            getUser();
            use();
            refresh()
            $('#datasave').attr('action','/position/addActivity')
        }else
            if(type==1){//查看
            var pId=$(this).parents('tr').attr('pId')
            $('.preservation').hide();
            $('.release3').hide();
            getUser()
            noUser();
            $('.dwbtn').hide()
            // detail(pId)
            look(pId)
        }else{//修改
                $('.tableList').hide();
                $('.mainBg').show();
            var pId=$(this).parents('tr').attr('pId')
            $('.preservation').attr('data-type','2')
            $('.preservation').show();
            $('.release3').show();
            $('.dwbtn').show()
            $('#datasave').attr('action','/position/updateActivityById?pId='+pId)
            use();
            getUser();
           detail(pId);
        }
        //     else{//修改
        //     var pId=$(this).parents('tr').attr('pId')
        //     $('.preservation').attr('data-type','2')
        //     $('.preservation').show();
        //     $('.release3').show();
        //     $('#datasave').attr('action','/position/updateActivityById?pId='+pId)
        //     use();
        //     getUser();
        //    detail(pId);
        // }
    })
    //    点击返回
    $('.getBack').click(function(){
        $('.tableList').show();
        $('.mainBg').hide();
    })
    //    点击坐标定位
    $('.dwbtn').click(function () {
//        window.open('/street/chooseMap')
        window.open('/street/mapCoordinates?type=4')
    })
    //    设置坐标
    function setZuobiao(str){
//        $('.gridLocation').val(str)
        $('input[name="gridLocation"]').val(str)
    }
    //    禁用
    function noUser(){
        $('input[type="text"]').attr('disabled','disabled');
        $('input[type="radio"]').attr('disabled','disabled');
        $('textarea').attr('disabled','disabled');
        $('select').attr('disabled','disabled');
    }
    //    可以使用
    function use(){
        $('input[type="text"]').removeAttr('disabled');
        $('input[type="radio"]').removeAttr('disabled');
        $('textarea').removeAttr('disabled');
        $('select').removeAttr('disabled','disabled');
    }
    function getUser(){
        $.ajax({
            url:'/orgGoviment/getSqlType',
            type:'get',
            dataType:'json',
            success:function(res){
                var data=res.object;
                $('input[name="senduser"]').val(data.senduser);
                //格式化时间
                var date=new Date();
                var year=date.getFullYear();
                var Month=date.getMonth()+1;
                var days=date.getDate();//获取当前是几号
                var H=date.getHours();
                var Min=date.getMinutes();
                var sec=date.getSeconds();
                $('input[name="publishTime"]').val(year+'-'+Month+'-'+days+' '+H+':'+Min+':'+sec)

            }
        })
    }
    //    分页列表
    var ajaxPageLe={
        data:{
            page:1,//当前处于第几页
            pageSize:10,//一页显示几条
            useFlag:true
            // computationNumber:null
        },
        page:function () {
            var me=this;
            $.ajax({
                url:'/position/getActivityList?orgDeptId=1',
                type:'get',
                data:me.data,
                dataType:'json',
                success:function(reg){
                    var datas=reg.obj;
                    var str="";
                    for(var i=0;i<datas.length;i++){
                        var sj =getNowFormatDate(datas[i].sendtime)
                        str+=' <tr pId="'+datas[i].pId+'">' +
//                            '                    <td>' +
//                            '                        <input type="checkbox" class="childCheck">' +
//                            '                    </td>' +
                            '                    <td>'+(i+1)+'</td>' +
                            '                    <td>'+datas[i].orgDeptName+'</td>' +
                            '                    <td><div class="lue" title="'+datas[i].activityPlace+'">'+datas[i].activityPlace+'</div></td>'+
                            '                    <td><div class="lue" title="'+datas[i].name+'">'+datas[i].name+'</div></td>'+
                            '                    <td><div class="lue" title="'+datas[i].place+'">'+datas[i].place+'</div></td>'+
                            '                    <td>'+datas[i].area+'</td>' +
                          //  '                    <td>'+datas[i].application+'</td>' +
                            '                    <td>' +
                            '                        <a href="javascript:;" class="choose" data-type="1">查看</a>' +
                            '                        <a href="javascript:;" class="choose up" data-type="2">修改</a>' +
                            '                        <a href="javascript:;" class="del de" >删除</a>' +
                            // '                        <a href="javascript:;" class="choose" data-type="2">修改</a>' +
                            // '                        <a href="javascript:;" class="del">删除</a>' +
                            '                    </td>' +
                            '                </tr>'
                    }
                    $('.list').html(str);
                    if(tag!=1){
                        $(".de").css("display","none")
                        $(".up").css("display","none")
                    }
                    if(reg.totleNum>10){
                        $('#dbgz_page').show();
                        me.pageTwo(reg.totleNum,me.data.pageSize,me.data.page)
                    } else {
                        $('#dbgz_page').hide();
                    }

                }
            })

        },
        pageTwo:function (totalData, pageSize,indexs) {
            var mes=this;
            $('#dbgz_page').pagination({
                totalData: totalData,
                showData: pageSize,
                jump: true,
                coping: true,
                homePage:'',
                endPage: '',
                current:indexs||1,
                callback: function (index) {
                    mes.data.page=index.getCurrent();
                    mes.page();
                }
            });
        }
    }
    ajaxPageLe.page();
    //    点击全选
    $('#checkAll').click(function(){
        var state=$(this).prop('checked');
        if(state == true){
            $(this).prop('checked',true);
            $('.childCheck').prop('checked',true);
        }else{
            $(this).prop('checked',false);
            $('.childCheck').prop('checked',false);
        }
    })
    //    点击删除
    $('.list').on('click','.del',function(){
        var pId=$(this).parents('tr').attr('pId')
        layer.confirm(' 确定要删除吗', {
            btn: ['确定', '取消'], //按钮
            title: " 删除"
        },function(){
            $.ajax({
                url:'/position/deleteActivityById',
                type:'post',
                dataType:'json',
                data:{pId:pId},
                success:function(){
                    layer.msg(' 删除成功', {icon: 6});
                    ajaxPageLe.page();
                }
            })
        }, function () {
            layer.closeAll();
        })
    })

    //    获取所属社区下拉框内容
   $.get('/code/GetDropDownBox',function (json) {
       if(json.flag){
           var str='';
           for(var i=0;i<json.obj.length;i++){
               str+='<option value="'+json.obj[i].orgDeptId+'">'+json.obj[i].orgDeptName+'</option>'
           }
           $('#grid').html(str)
       }
   })

     $.ajax({
         url: '/code/GetDropDownBox',
         type: 'get',
         data:{
             CodeNos:"TYPE_OF_ACCOUNT"
         },
         dataType: 'json',
         success: function (obj) {
             var str='<option value="">请选择</option>';
             var data=obj.TYPE_OF_ACCOUNT;
             for(var i=0;i<data.length;i++){
                 str+='<option value="'+data[i].codeNo+'">'+data[i].codeName+'</option>';
             }
             $("#communityNo").html(str);
         }
     })

    //获取下拉框内容根据
   $.ajax({
       url: '/gridInfo/gridSettingsTreeList',
       type: 'get',
       dataType: 'json',
       success: function (obj) {
           var str='<option value="">请选择</option>';
           var data=obj.obj;
           for(var i=0;i<data.length;i++){
               str+='<option value="'+data[i].gridId+'">'+data[i].gridName+'</option>';
           }
           $("#communityNo").html(str);
       }
   })

    //    点击保存
    $('.preservation').click(function(){
        var type=$(this).attr('data-type');
    $('.preservation').click(function(){
        var type=$(this).attr('data-type');

        if($('#deptParent').val()!=''){
            var sj=$('#deptParent').attr('deptid');
            var deptId = sj.substr(0,sj.indexOf(","))
            $('#orgDeptId').val(deptId);
        }
        if($('input[name="gridLocation"]').val()==""){
            $.layerMsg({content:'请选取坐标',icon:6})
            return;
        }
        if($('#communityNo option:selected').val()==''){
            $.layerMsg({content:'请填写社区',icon:7})
        } else  if( $('#deptParent').val()==''){
            $.layerMsg({content:'请选择组织',icon:7})
        } else {

            if(type==0){//新建
                $('#datasave').ajaxSubmit({
                    type:'post',
                    dataType:'json',
                    success:function(res){
                        if(res.flag){
                            $.layerMsg({content:'新建成功',icon:1})
                            $('.tableList').show();
                            $('.mainBg').hide();
                            ajaxPageLe.data.page=1;
                            ajaxPageLe.page();
                        }else{
                            $.layerMsg({content:'新建失败',icon:2})
                        }
                    }
                })
            }else if(type==2){
                $('#datasave').ajaxSubmit({
                    type:'post',
                    dataType:'json',
                    success:function(res){
                        if(res.flag){
                            $.layerMsg({content:'修改成功',icon:1})
                            $('.tableList').show();
                            $('.mainBg').hide();
                            ajaxPageLe.data.page=1;
                            ajaxPageLe.page();
                        }else{
                            $.layerMsg({content:'修改失败',icon:1})
                        }
                    }
                })
            }
        }

    })

        if($('#deptParent').val()!=''){
            var sj=$('#deptParent').attr('deptid');
            var deptId = sj.substr(0,sj.indexOf(","))
            $('#orgDeptId').val(deptId);
        }
        if($('input[name="gridLocation"]').val()==""){
            $.layerMsg({content:'请选取坐标',icon:6})
            return;
        }
        if($('#communityNo option:selected').val()==''){
            $.layerMsg({content:'请填写社区',icon:7})
        } else  if( $('#deptParent').val()==''){
            $.layerMsg({content:'请选择组织',icon:7})
        } else {

            if(type==0){//新建
                $('#datasave').ajaxSubmit({
                    type:'post',
                    dataType:'json',
                    success:function(res){
                        if(res.flag){
                            $.layerMsg({content:'新建成功',icon:1})
                            $('.tableList').show();
                            $('.mainBg').hide();
                            ajaxPageLe.data.page=1;
                            ajaxPageLe.page();
                        }else{
                            $.layerMsg({content:'新建失败',icon:2})
                        }
                    }
                })
            }else if(type==2){
                $('#datasave').ajaxSubmit({
                    type:'post',
                    dataType:'json',
                    success:function(res){
                        if(res.flag){
                            $.layerMsg({content:'修改成功',icon:1})
                            $('.tableList').show();
                            $('.mainBg').hide();
                            ajaxPageLe.data.page=1;
                            ajaxPageLe.page();
                        }else{
                            $.layerMsg({content:'修改失败',icon:1})
                        }
                    }
                })
            }
        }

    })

    //    查看详情
    function  detail(pId) {
//        console.log($.cookie('meId'))

        $.ajax({
            url:'/position/getActivityById',
            data:{pId:pId},
            dataType:'json',
            type:'get',
            success:function(res){
                var data=res.object;
//                $('.gridLocation').val(data.remark2);//灶头数
                $('input[name="gridLocation"]').val(data.remark2)
                var sj =getNowFormatDate(data.startTime)
                var sjs =getNowFormatDate(data.endTime)
                $.ajax({
                    url: '/code/GetDropDownBox',
                    type: 'get',
                    data:{
                        CodeNos:"TYPE_OF_ACCOUNT"
                    },
                    dataType: 'json',
                    success: function (obj) {
                        var str='<option value="">请选择</option>';
                        var datas=obj.TYPE_OF_ACCOUNT;
                        for(var i=0;i<datas.length;i++){
                            if(datas[i].codeNo == data.communityNo){
                                str+='<option selected value="'+datas[i].codeNo+'">'+datas[i].codeName+'</option>';
                            }else{
                                str+='<option value="'+datas[i].codeNo+'">'+datas[i].codeName+'</option>';
                            }


                        }
                        $("#communityNo").html(str);
                    }
                })
               // $('input[name="communityNo"]').val(data.communityNo);//单位
             //   $('#communityNo').val(data.communityNo).attr("selected",true);

                $('input[name="activityPlace"]').val(data.activityPlace)//单位地址
                $('input[name="name"]').val(data.name)//单位地址
                $('input[name="place"]').val(data.place)//单位地址
//                $('#grida').val(data.type).attr("selected",true);
                $('input[name="area"]').val(data.area);//联系电话
//                $('#times').val(sjs);//经营面积
//                $('#time').val(sj);//经营面积
                $('#application').val(data.application)
//                $('input[name="application"]').val(data.application);//灶头数
                $('#remark1').val(data.remark1)
//                $('input[name="remark1"]').val();//灶头数
                $('input[name="orgDeptId"]').val(data.orgDeptId);//灶头数
                $('#deptParent').val(data.orgDeptName);
                $('#deptParent').attr("deptid",data.orgDeptId);
                $('#orgDeptId').val(data.orgDeptName);
                $('#orgDeptId').attr("deptid",data.orgDeptId);
            }
        })
    }

    function look(pId) {
        $.ajax({
            url:'/position/getActivityById',
            data:{pId:pId},
            dataType:'json',
            type:'get',
            success:function(res){

                var data=res.object;
//                $('.gridLocation').val(data.remark2);//灶头数
                $('input[name="gridLocation"]').val(data.remark2)
                var sj =getNowFormatDate(data.startTime)
                var sjs =getNowFormatDate(data.endTime)
                $('input[name="activityPlace"]').val(data.activityPlace)//单位地址
                $('input[name="name"]').val(data.name)//单位地址
                $('input[name="place"]').val(data.place)//单位地址

                $('input[name="area"]').val(data.area);//联系电话

                $('#application').val(data.application)
//                $('input[name="application"]').val(data.application);//灶头数
                $('#remark1').val(data.remark1)
//                $('input[name="remark1"]').val();//灶头数
                $('input[name="orgDeptId"]').val(data.orgDeptId);//灶头数
                $('#deptParent').val(data.orgDeptName);
                $('#deptParent').attr("deptid",data.orgDeptId);
                $('#orgDeptId').val(data.orgDeptName);
                $('#orgDeptId').attr("deptid",data.orgDeptId);

                layer.open({
                    type: 1,
                    title: '活动详情',
                    // shade: 0.5,
                    area: ['60%', '80%'],
                    btn:['关闭'],
                    content:' <div class="mainBg" style="background: #fff;">\n' +
                        '        <form action="/position/addActivity" id="datasave">\n' +
                        '            <input type="hidden" name="">\n' +
                        '            <input type="hidden" name="">\n' +
                        '            <div class="mainTitle" style="width:90%;background:#f6f6f6;border:none;height: auto !important;">\n' +
                        '                <ul class="mainTitleUl">\n' +
                        '                    <li style="padding-top: 10px;text-align: center;height: 10px !important;border-bottom: none !important;"><span class="spanSize"></span> </li>\n' +
                        '                    <li class="bordercolor clearfix">\n' +
                        '                        <span style="margin-top: -26px;"><b>*</b>组织架构</span>\n' +
                        '                        <label style="width: 80%;margin-top: -32px;">\n' +
                        '                            <input type="text"  name="orgDeptId" id="orgDeptId" style="display:none;"/>\n' +
                        '                            <input type="text" value="'+data.orgDeptName+'" id="deptParent" name="deptParent" readonly="readonly" placeholder="请选择组织架构" style="background: #fcfcfc;width: 55%;float: none;margin-top:17px "  dept_id="">\n' +
                        '                        </label>\n' +
                        '                    </li>\n' +
                        '                    <li class="bordercolor clearfix">\n' +
                        '                        <span style="">坐标<b style="color: red;">*</b></span>\n' +
                        '                        <label style="width: 47%;position:relative">\n' +
                        '                            <input type="text" value="'+data.remark2+'" name="gridLocation" style="width:92%" readonly="readonly">\n' +
                        // '                            <button type="button" class="dwbtn" style="position: absolute;width: 82px;height: 39px; background-color: #228cdc;color: #fff; right: -62px;top:9px;border-radius: 3px;cursor: pointer;">点击定位</button>\n' +
                        '                        </label>\n' +
                        '                    </li>\n' +
                        '                    <li class="bordercolor clearfix">\n' +
                        '                        <span style="margin-top: -12px;">活动场所</span>\n' +
                        '                        <label>\n' +
                        '                            <input type="text" value="'+data.activityPlace+'" name="activityPlace"  placeholder="请填写活动场所" style="background: #fcfcfc;width: 147%;float: none; margin-top: -4px;">\n' +
                        '                        </label>\n' +
                        '                        <label style="width: 50%;"></label>\n' +
                        '                    </li>\n' +
                        '                    <li class="bordercolor clearfix">\n' +
                        '                        <span style="margin-top: -22px;">名称</span>\n' +
                        '                        <label>\n' +
                        '                            <input type="text" value="'+data.name+'" name="name"  placeholder="请填写名称" style="background: #fcfcfc;    width: 147%;float: none;margin-top:-16px;">\n' +
                        '                        </label>\n' +
                        '                        <label style="width: 50%;"></label>\n' +
                        '                    </li>\n' +
                        '                    <li class="bordercolor clearfix">\n' +
                        '                        <span style="margin-top: -36px;">位置</span>\n' +
                        '                        <label>\n' +
                        '                            <input type="text" value="'+data.place+'" id="times" name="place" placeholder="请填写位置" style="background: #fcfcfc;    width: 147%;float: none; margin-top: -28px;">\n' +
                        '                        </label>\n' +
                        '                        <label style="width: 50%;"></label>\n' +
                        '                    </li>\n' +
                        '                    <li class="bordercolor clearfix">\n' +
                        '                        <span style="margin-top: -46px;">面积</span>\n' +
                        '                        <label>\n' +
                        '                            <input type="text" value="'+data.area+'" name="area" placeholder="请填写面积" style="background: #fcfcfc;    width: 147%;float: none; margin-top: -40px;">\n' +
                        '                        </label>\n' +
                        '                        <label style="width: 50%;"></label>\n' +
                        '                    </li>\n' +
                        '                    <li class="bordercolor clearfix" style="    margin-top: 23px;">\n' +
                        '                        <span  style="margin-top: -76px;">用途</span>\n' +
                        '                        <label style="    height: 89px;">\n' +
                        '                            <textarea name="application" id="application" style="background: #fcfcfc;border: none; width: 147%;height: 70px!important;font-size:14px;float: none; margin-top: -66px;margin-left: 66%;" readonly>'+data.application+'</textarea>\n' +
                        '                            <%--<input type="text" name="application"  placeholder="请填写用途" style="background: #fcfcfc;    width: 147%;float: none; margin-top: -53px;">--%>\n' +
                        '                        </label>\n' +
                        '                        <label style="width: 50%;"></label>\n' +
                        '                    </li>\n' +
                        '                    <li class="bordercolor clearfix">\n' +
                        '                        <span style="margin-top: -76px;">备注</span>\n' +
                        '                        <label>\n' +
                        '                            <%--<input type="text" name="remark1" style="background: #fcfcfc; width: 147%;float: none; margin-top: -66px;margin-left: 66%;">--%>\n' +
                        '                            <textarea name="remark1" id="remark1" style="background: #fcfcfc; width: 147%;height: 70px!important;font-size:14px;float: none; margin-top: -66px;margin-left: 66%;border: none;" readonly>'+data.remark1+'</textarea>\n' +
                        '                        </label>\n' +
                        '                    </li>\n' +
                        '                </ul>\n' +

                        // '                <div style="height: 100px;line-height: 80px;text-align: center;    margin-top: -95px;">\n' +
                        // '                <div style="display: flex;justify-content: center;width: 100%;">\n' +
                        // '                    <a href="javascript:void (0)" class="preservation" style="\n' +
                        // '               display: inline-block;margin-right: 10px;\n' +
                        // '                line-height: 1;font-size:18px;padding: 8px 20px;\n' +
                        // '                background: #2F8AE3;color: #fff;border-radius: 6px">保存</a>\n' +
                        // '                    <a href="javascript:void (0)" class="getBack"  style="\n' +
                        // '                display: inline-block;\n' +
                        // '                line-height: 1;font-size:18px;padding: 8px 20px;background: #2F8AE3;color: #fff;border-radius: 6px">返回</a>\n' +
                        // '                </div>\n' +
                        // '                </div>\n' +

                        '            </div>\n' +
                        '        </form>\n' +
                        '    </div>',
                    success:function(res){
                        $('input').css('border','none')
                        $('input').attr('readonly','readonly')
                    }
                    ,yes: function(index, layero){
                        layer.close(index)
                        $('input').css('border','1px solid #DFE4EB')
                        $('input[type="text"]').removeAttr('readonly');

                    }
                })
            }
        })
    }


    //    ridio check
    function check(name,data){
        $(':radio[name="'+name+'"][value="'+data+'"]').prop('checked','check')

    }
    //    点击查询
    $('#query').click(function(){
        ajaxPageLe.data.unit=$('.info').val();
        ajaxPageLe.page();
    })

    //    点击导入
    $('#inport').click(function(){
        layer.open({
            type:1,
            title: ['动态监控台账信息导入', 'background-color:#2b7fe0;color:#fff;'],
            area: ['600px', '420px'],
            btn: ['导入', '取消'],
            content:'<div>' +
            '<form class="form1" name="form1" id="uploadForm" method="post" action="/enCaterParameter/importEnCaterParameter\n" enctype="multipart/form-data">' +
            '<table class="importTable"> ' +
            '<tr><td style="width: 100px;">下载导入模板：</td><td style="text-align: left;"><a id="model" style="cursor:pointer">动态监控台账信息模板下载</a></td></tr>' +
            '<tr> <td>选择导入文件：</td> <td><input style="width: auto" type="file" name="file"/></td> </tr>' +
            '<tr>' +
            '<td>说明：</td>'+
            '<td style="text-align: left;"><p>1、请导入.xls文件或者.xlsx。</p>'+
//            '<p>2、请填写网格信息中已有网格。</p>'+
            ' </td> ' +
            '</tr>' +
            '</table>' +
            '</form>' +
            '</div>',
            success:function(){
                $('#model').click(function () {
                    window.location.href = encodeURI("/file/grid/business_account.xls");
                });
            },
            yes:function(obj){
                var flag = CheckForm();
                if (flag) {
                    layer.msg("正在导入中，请耐心等候", {icon: 1});
                    $.upload($('#uploadForm'), function (res) {
                        if(res.flag) {
                            layer.msg("导入成功", {icon: 1});
                        }else{
                            layer.msg("导入失败", {icon: 2});
                        }
                    });

                    layer.closeAll();
                }
            }
        })
    });
    function CheckForm(){
        if(document.form1.file.value==""){
            layer.msg("请导入至少一条数据！",{icon:2});
            return (false);
        }
        return (true);
    }

    //    点击导出
    $('#outport').click(function(){
        if($('.childCheck:checked').length<=0){
            $.layerMsg({content:'请选择至少一条数据',icon:6})
        }else{
            var arr=[]
            $('.childCheck:checked').each(function(){
                var id=$(this).parents('tr').attr('id');
                arr.push(id)
            })
            var str=arr.join()
            console.log(str)
            window.location.href= '<%=basePath%>inspectorProblem/outPutFile?ids='+str;
        }

    })

    //    重置
    function refresh(){
        $('input[name="gridLocation"]').val('');//灶头数
        $('input').val('');//单位
        $('input[name="unitAddress"]').val('')//单位地址
        $("#grid").find("option[value='']").attr("selected",true); //所属社区
        $('input[name="cantact"]').val('');//联系人
        $('input[name="phoneNumber"]').val('');//联系电话
        $('input[name="businessArea"]').val('');//经营面积
        $('#note').val('');//备注
        $('#application').val('')
        $('#remark1').val('')
    }
    function getNowFormatDate(tm) {
        var date = new Date(tm);
        var seperator1 = "-";
        var seperator2 = ":";
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        var Hours = date.getHours();
        var Minutes = date.getMinutes();
        var Seconds = date.getSeconds();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        if (Hours >= 0 && Hours <= 9) {
            Hours = "0" + Hours;
        }
        if (Minutes >= 0 && Minutes <= 9) {
            Minutes = "0" + Minutes;
        }
        if (Seconds >= 0 && Seconds <= 9) {
            Seconds = "0" + Seconds;
        }
        var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
            ' ' + Hours + seperator2 + Minutes +
            seperator2 + Seconds;
        return currentdate;
    }
    var time = {
        elem:'#time',
        format:'YYYY-MM-DD hh:mm:ss',
        min:laydate.now(),
        max:'2999-12-31 23:59:59',
        istime:true,//是否显示时分秒
        istoday:true,//是否显示【今天】的按钮
        isclear:true,//是否显示【清空】的按钮
        festival: true,//是否显示节日
        start: laydate.now(0,"YYYY-MM-DD hh:mm:ss"),  // 开始日期
        fixed: false,   // 是否固定在可视区域
        zIndex: 10000,  // css控制图层的遮罩效果（效果不明显）
        ready: function(dates){  // 选择好日期的回调
        }
    }
   // laydate(time);
    $('#time').val(laydate.now(0, 'YYYY-MM-DD hh:mm:ss'));
    
</script>
</body>
</html>

<script type="text/javascript">
    window.onload = function(){
        var _iframe4 = window.parent;
        var _div4 =_iframe4.document.getElementById('iframe4');
        // _div4.style.display = 'block';
    }
</script>
